//统一管理咱们项目用户相关的接口
import request from "@/utils/request";

import {MenuAddOrUpdateForm, MenuAllListResponseData, RoleMenuForm} from "@/api/business/menu/type";
import {HandleResponseData, UuidForm} from "@/api/common/type";


//项目用户相关的请求地址
enum API {
    //某用户拥有的全部权限
    allMenuUrl = "/bg/menu/allList",
    //某角色拥有的权限
    roleMenuListUrl = "/bg/menu/role",
    //详情
    menuInfoUrl = "/bg/menu/detail",
    //编辑
    updateMenuUrl = "/bg/menu/update",
    //添加
    addMenuUrl = "/bg/menu/add",
    //删除
    delMenuUrl = "/bg/menu/batchDel",
    //分配权限
    menuRoleUrl = "/bg/role/menu",
    //顶级目录
    allTopMenu = "/bg/menu/allTopList"
}

//全部权限
export const reqAllMenu = () => request.get<any, MenuAllListResponseData>(API.allMenuUrl);
//某角色拥有的权限
export const reqRoleMenu = (roleUuid: string) => request.get<any, MenuAllListResponseData>(API.roleMenuListUrl +`?roleUuid=${roleUuid}`);

//分页列表
// export const reqPageListRole = (page: number, pageSize: number,roleNameLike: string) => request.get<any, RolePageListReponseData>(API.pageListUrl +`?roleNameLike=${roleNameLike}&page=${page}&pageSize=${pageSize}`);
//
// export const reqRoleInfo = (uuid: string) => request.get<any, RolePageListReponseData>(API.roleInfoUrl +`?uuid=${uuid}`);
//
export const reqAddOrUpdateMenu = (data: MenuAddOrUpdateForm) => {
    if (data.uuid) {
        return request.post<any, HandleResponseData>(API.updateMenuUrl, data);
    } else {
        return request.post<any, HandleResponseData>(API.addMenuUrl, data);
    }
}
//删除权限
export const reqDelMenu = (uuidFrom: UuidForm) => request.post<any, HandleResponseData>(API.delMenuUrl,uuidFrom);
//分配权限
export const reqMenuRole = (date: RoleMenuForm) => request.post<any, HandleResponseData>(API.menuRoleUrl,date);
//全顶级目录
export const allTopMenu = () => request.get<any, MenuAllListResponseData>(API.allTopMenu);

